<template>
	<view class="news">
		
		<carts-item @cartsItemClick="goGoodsDetatil" :detriment="cartslist" ></carts-item>
		

	</view>
</template>

<script>
	import cartsItem from '../../components/carts-item/carts-item.vue'
	export default{
		data(){
			return{
				cartslist:[],
				uid:0,
				phone:'',
			}
		},
		methods:{
			async getUserInfo(){
				const res = await this.$myRequest({
							url: '/user/getUserInfo'
							})
							// console.log(res)
							console.log(res)
							this.cartslist=res.data
							console.log(this.cartslist[0])
							this.uid=res.data[1]
							this.phone=res.data[0]
							
										
			},
			async getCarts(){
			const res = await this.$myRequest({
						url: '/getAllcar?uid='+this.uid
						})
						// console.log(res)
						this.cartslist=res.data
						console.log(this.cartslist)
						
										
		},
		goGoodsDetatil (uid) {
			uni.navigateTo({
				url: '/pages/goods-detail/goods-detail?id='+1
			})
		}
		
		},
		components: {"carts-item":cartsItem},
		onShow() {
				if(this.phone!='fail'){
					this.getCarts()
				}
			},
			onLoad(){
				if(this.phone!='fail'){
					
					this.getUserInfo()
				}
			}

		
	}
</script>

<style>
</style>
